 window.onload = function () {
        var oForm = document.getElementById('loginForm');
        var oUser = document.getElementById('user');
        var oPswd = document.getElementById('pswd');
        var oRemember = document.getElementById('remember');
        //页面初始化时，如果帐号密码cookie存在则填充
        if (getCookie('user') && getCookie('pswd')) {
            oUser.value = getCookie('user');
            oPswd.value = getCookie('pswd');
            oRemember.checked = true;
        }
        //复选框勾选状态发生改变时，如果未勾选则清除cookie
        oRemember.onchange = function () {
            if (!this.checked) {
                delCookie('user');
                delCookie('pswd');
            }
        };
        //表单提交事件触发时，如果复选框是勾选状态则保存cookie
        oForm.onsubmit = function () {
            if(oUser.value === ""||oPswd.value === ""){
                alert('请正确填写信息');
                return false;
            }
            if (remember.checked) {
                setCookie('user', oUser.value); //保存帐号到cookie，有效期7天
                setCookie('pswd', oPswd.value); //保存密码到cookie，有效期7天
                alert('记住密码成功');
                alert('登陆成功');
            }else{
                alert('登陆成功');
            }
        };
    };

    //设置cookie
    function setCookie(name, value) {
        localStorage.setItem(name, value);
    };

    //获取cookie
    function getCookie(name) {
        return localStorage.getItem(name);
    };

    //删除cookie
    function delCookie(name) {
        localStorage.removeItem(name);
    };